<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE HTML>
<html>
<head>
<title>My JSP 'result.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<link href="assets/ico/biologo.ico" rel="shortcut icon">
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/bootstrap-popover.js"></script>
<script type="text/javascript" src="js/bootstrap-scrollspy.js"></script>
<script type="text/javascript" src="js/bootstrap-tab.js"></script>

<style type="text/css">
body {
	background-image: url("");
}

#diseases {
	margin-top: 12px;
	margin-left: 20%;
	margin-right: 20%;
}

form {
	font-size: 16px;
}

#titlediv {
	margin-bottom: 0px;
}

.content {
	padding-left: 18px;
	background-color: #E8F5F7;
}

.add-on {
	font-size: 14px;
}

.form-actions {
	margin-right: 52%;
}

.diseases {
	position: absolute;
	top: 0px;
	width: 700px;
	margin-top: 10px;
	margin-left: 360px;
}

.scrollspy-example {
	height: 200px;
	overflow: auto;
	position: relative;
}

.leftDiv {
	width: 200px;
}
</style>
</head>
<body>
	<%@ include file="include/topbar.jsp"%>
	<%@ include file="include/leftCategory.jsp"%>
	<div class="diseases">
	
	<hr />
		<img alt="" src="img/baolude-logo.gif">
		<hr /><i class="icon-home"></i>
		<a class="tohomePage" href="togetHomePageOfDisease.action">回主页</a>》》》<%-- <a
			href="javascript:history.go(-1);">搜索疾病列表</a>》》》--%><i class="icon-list"></i>导出的疾病列表
		<hr />

		<a style="cursor: pointer;display:inline;" class="getOrder"
			href="javascript:void(0)">下订单</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span
			id="tishi1" style="color#999;display: none">您还没有选择要测试的项目o(╯□╰)o</span>
		<table class="table table-bordered">
			<thead>
				<tr>
					<th width="10%">疾病名称</th>
					<th width="15%">测试项目</th>
					<th width="25%">测试</th>
					<th width="20%">检测的大类型</th>
					<th width="15%">小类型</th>
					<th width="15%">测试名称</th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<s:iterator var="entry0" value="#request.map" status="st0">
						<tr>
							<%---第一列的遍历 --%>
							<s:if test="st0.index!=0">
								<tr>
							</s:if>
							<td rowspan="<s:property value='key.testItems.size()'/>"><s:property
									value="#entry0.key.name" /></td>


							<s:iterator var="entry1" value="#entry0.value" status="st1">
								<s:if test="st1.index!=0">
									<tr>
								</s:if>
								<%--第二列的遍历 --%>
								<td
									rowspan="<s:property value='#request.maprows1[#entry0.key][key]'/>">
									<s:property value="#entry1.key" />
								</td>
								<s:iterator var="entry2" value="#entry1.value" status="st2">
									<s:if test="st2.index!=0">
										<tr>
									</s:if>
									<%-- 第三列的遍历--%>
									<td class="testForThird"
										rowspan="<s:property value='#request.maprows2[#entry0.key][#entry1.key][#entry2.key]'/>">
										<s:set var="to" value="''" /> <s:iterator value="#entry2.key"
											var="test0">
											<%--<input type="radio" 
												name="radio+<s:property value="#entry2"/>" />
											--%>
											<s:set var="to" value="#to + #test0.code + ','" />
										</s:iterator> <s:if test="#to.length() != 0">
											<s:set var="to" value="#to.substring(0, #to.length() - 1)" />
										</s:if> <span class=""><s:property value="#to" /> </span>
									</td>
									<s:iterator var="entry3" value="#entry2.value" status="st3">
										<%--第四列的遍历 所属大类型的循环--%>
										<s:if test="st3.index!=0">
											<tr>
										</s:if>

										<td rowspan="<s:property value="value.size()"/>"><s:property
												value="key" />
										</td>
										<s:iterator var="entry4" value="#entry3.value" status="st4">
											<%--第五列的遍历小类型 --%>
											<s:if test="st4.index!=0">
												<tr>
											</s:if>
											<td><s:property value="testType" /></td>
											<%-- 第六列的遍历   測試的名稱
												value的值为：主键值_所属基因(酶/代谢)_所属病名
												name 的值为：testType_<s:property value='#st3.index'/>_<s:property value='#st2.index'/>_<s:property value='#st1.index'/>_<s:property value='#st0.index'/>
												class判断复选框中的是是否是一个大类
												class="<s:property value='#entry0.key.sn' />_<s:property value='key' />"
											--%>
											<td><input type="checkbox"
												to="<s:property value="#to"/>"
												class="cat_<s:property value="#entry3.key.hashCode()"/>_<s:property value="#entry1.key.hashCode()"/>"
												value="<s:property value='sn'/>_<s:property value='#entry1.key'/>_<s:property value='#entry0.key.sn'/>"
												<%-- name="testType_<s:property value='#st3.index'/>_<s:property value='#st2.index'/>_
																<s:property value='#st1.index'/>_<s:property value='#st0.index'/>"--%>
												name="testType_<s:property value="#entry3.key.hashCode()"/>_<s:property value="#entry2.key.hashCode()"/>_<s:property value="#entry1.key.hashCode()"/>" />
												<s:property value="name" />
											</td>

											<%--<td><input type="radio" class="radio"
												value="<s:property value='sn'/>_<s:property value='#entry1.key'/>_<s:property value='#entry0.key.sn'/>"
												name="testType_<s:property value='#st3.index'/>_<s:property value='#st2.index'/>_<s:property value='#st1.index'/>_<s:property value='#st0.index'/>" onchange="disappare1()"/>
												<s:property value="name" />
											</td>--%>
						</tr>
					</s:iterator>
					</s:iterator>
					</s:iterator>
					</s:iterator>
					</s:iterator>
				</tr>
			</tbody>
		</table>
	</div>
	<span class="hiddenTIS" style="display:none;">${selectTestItems
		}</span>
	<%--<input name="diseaseListHidden" type="hidden" value="${diseaseList}" />	<c:forEach var="disease" items="${diseaseList}">
		<input type="hidden" name="hiddenDisease" value="${disease.sn}"/>
	</c:forEach>
	<span id="haveChooseDisease" style="display:none;">${selectTestItems }</span>
	--%>
	<input type="button" id="myBtnId" value="测试按钮" />
	<%--<c:forEach var="testItem" items="${testItemList}">
		<span class="haveChooseTI">选择后的testItem的sn的值：${testItem.sn }</span>
	</c:forEach>
--%>
	<c:forEach var="strOfTestI" items="${testItemsHadChoose}">
		<span style="display: inline;" class="strOfTestI">${strOfTestI}</span>
	</c:forEach>


</body>
<script type="text/javascript">
	var selectedtis = '<s:property value="#session.selectTestItems"/>';
	var selectedtimap = {};
	$(function() {
		$(".testForThird").each(
				function() {
					var str = $(this).text().replace(/\n/g, "").trim().replace(
							/\s/g, "");
					var lastIndex = str.lastIndexOf(',');
					if (lastIndex > -1) {
						str = str.substring(0, lastIndex)
								+ str.substring(lastIndex + 1, str.length);
					}
				});
	});
	$(function() {
		var seltiary1 = selectedtis.split(",");
		for ( var i = 0; i < seltiary1.length; i++) {
			if (seltiary1[i] != "") {
				var seltiary2 = seltiary1[i].split("_");
				selectedtimap['p' + seltiary2[0]] = seltiary1[i];
			}
		}
		$("input[type='checkbox']")
				.each(
						function() {
							if (selectedtimap.hasOwnProperty('p'
									+ this.value.split("_")[0])) {
								this.checked = true;
							}
							$(this)
									.click(
											function() {
												if (this.checked) {
													var re = /cat_\d+_\d+/;
													var clsstr = this.className;
													var tgtclz = re
															.exec(clsstr)[0];
													var coll = $("input:checkbox:checked."
															+ tgtclz);
													var selectedtos = {};
													var onecb = this;
													var curtos = $(onecb).attr(
															"to").split(",");
													coll
															.each(function() {
																if (this != onecb) {
																	var tmptos = $(
																			this)
																			.attr(
																					"to")
																			.split(
																					",");
																	for ( var i = 0; i < curtos.length; i++) {
																		for ( var j = 0; j < tmptos.length; j++) {
																			if (curtos[i] == tmptos[j]) {
																				selectedtos[curtos[i]] = 1;
																			}
																		}
																	}
																}
															});
													var repeattos = "";
													for ( var p in selectedtos) {
														repeattos += p + ",";
													}
													if (repeattos != "") {
														repeattos = repeattos
																.substring(
																		0,
																		repeattos.length - 1);
													}
													var checkboxs = document
															.getElementsByName(this.name);
													for ( var j = 0; j < checkboxs.length; j++) {
														if (this != checkboxs[j]
																&& checkboxs[j].checked) {
															checkboxs[j].checked = false;
															var cbsn = checkboxs[j].value
																	.split("_")[0];
															if (selectedtimap
																	.hasOwnProperty("p"
																			+ cbsn)) {
																delete selectedtimap["p"
																		+ cbsn];
															}
														}
													}
													selectedtimap["p"
															+ this.value
																	.split("_")[0]] = this.value;
													if (repeattos.length != 0) {
														alert("已有选中的基因/酶！"
																+ repeattos);
													}
												}
											});
						});
	});
	$(function() {
		function disappare1() {
			$("#tishi1").css("display", "none");
		}
		$(".getOrder").click(function() {
			var str = "";
			for ( var key in selectedtimap) {
				str += selectedtimap[key] + ",";
			}

			var diseaseSn = "";
			$("input[name='hiddenDisease']").each(function() {
				diseaseSn = diseaseSn + $(this).val() + "_";
			});
			window.location.href = "toOrderpage.action?selectTestItems=" + str;
		});
		$("#advancedSearch").click(function() {
			$("#diseases").hide();
			$.post("anvencedsearch.action");
		});
		$("#before").click(
				function() {
					var nowP = parseInt($("#nowpage").val());
					if (nowP == 0) {
						return false;
					}
					nowP = nowP - 1;
					if (nowP < 0) {
						nowP = 0;
					}

					window.location.href = "quickSearch.action?nowPage=" + nowP
							+ "&searchname=" + $("#hiddensearchname").val();
				});
		$("#next").click(
				function() {
					var nextP = parseInt($("#nowpage").val());
					if (nextP == $("#lastpage").attr("rel")) {
						return false;
					}
					var m = parseInt($("#lastpage").attr("rel"));
					nextP = nextP + 1;
					if (nextP > m) {
						nextP = m;
					}
					window.location.href = "quickSearch.action?nowPage="
							+ nextP + "&searchname="
							+ $("#hiddensearchname").val();
				});
		$(".pagenum").click(
				function() {
					var page = $(this).attr("rel");
					if (parseInt(page) == (parseInt($("#nowpage").val()) + 1)) {
						return false;
					}
					window.location.href = "quickSearch.action?nowPage="
							+ (parseInt(page) - 1) + "&searchname="
							+ $("#hiddensearchname").val();
				});
		$("#firstpage").click(
				function() {
					if (parseInt($("#nowpage").val()) == ($("#firstpage")
							.attr("rel"))) {
						return false;
					}
					window.location.href = "quickSearch.action?nowPage="
							+ $("#firstpage").attr("rel") + "&searchname="
							+ $("#hiddensearchname").val();
					$("#firstpage").parent().addClass("active");
				});
		$("#lastpage").click(
				function() {
					if (parseInt($("#nowpage").val()) == ($("#lastpage")
							.attr("rel"))) {
						return false;
					}
					$("#hiddensearchname").val();
					window.location.href = "quickSearch.action?nowPage="
							+ $("#lastpage").attr("rel") + "&searchname="
							+ $("#hiddensearchname").val();
				});
	});
	$(function() {
		$(".btn-danger").click(function() {
			$(".well").popover("show");
		});
		$(".disease_type").click(
				function() {
					$.post("disease_type.action", {
						"sn" : $(this).attr("rel")
					}, function(data) {
						$("#diseaseTypevalue" + data.diseaseCategory.sn)
								.toggle();
						$("#diseaseTypevalueSub" + data.diseaseCategory.sn)
								.text(data.diseaseCategory.name);
					});
				});
	});
	$('#navbar').scrollspy();
	$('#myTab').tab('show');
</script>
</html>
